package com.example.unlits;

import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;

@Component
public class Unlit {

    private String[] patch = {"00000","0000","000","00","0"," "};

public String encryptionCode(String tole){
     int hash = tole.hashCode();
     int encryption = 20200710;

     long result = hash ^ encryption;
     long nowTime = System.currentTimeMillis();
     result = result ^ nowTime;
     long code= result % 1000000 ;
      code = code < 0 ? -code : code;

      String codeStr = code + "";

      int len = codeStr.length();

    return patch[len-1] +codeStr;


}
    @Cacheable(value = "codes",key = "#tole")
    public String get(String tole){
        return null;
    }

//    public static void main(String[] args) {
//        Unlit unlit = new Unlit();
//        unlit.encryptionCode("15840467318");
//    }
}
